<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0043)http://localhost:8080/mango/cart/list.jhtml -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

<title>我的地址</title>
<link href="${pageContext.request.contextPath}/css/common.css" rel="stylesheet" type="text/css"/>
<link href="${pageContext.request.contextPath}/css/cart.css" rel="stylesheet" type="text/css"/>
<link href="${pageContext.request.contextPath}/css/jquery_dialog.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery_dialog.js"></script>
<script type="text/javascript"/>
	// 二级联动菜单代码
	$(document).ready(function(){
		$("#area").change(function(){
			$("#area option").each(function(i,o){
				if($(this).attr("selected")){
					$(".region").hide();
					$(".region").eq(i).fadeIn("fast");
				}
			});
		});
		$("#area").change();
	});
	
	// 表单校验
	function checkForm(){
		var $p1 = $("#p1");
		// 收货人非空校验
		var name = $("#name").val();
		if(name == null || name == ""){
			$p1.show();
			$p1.html("<span>收货人不能为空!<span>");
			return false;
		}
		// 小区非空校验
		var $region = $("#region");
		if($region.css("display") == "none"){
			$p1.show();
			$p1.html("<span>小区没有选择!<span>");
			return false;
		}	
		// 详细地址非空校验
		var addr = $("#addr").val();
		if(addr == null || addr == ""){
			$p1.show();
			$p1.html("<span>详细地址不能为空!<span>");
			return false;
		}
		// 电话非空校验
		var phone = $("#phone").val();
		if(phone == null || phone == ""){
			$p1.show();
			$p1.html("<span>手机号码不能为空!<span>");
			return false;
		}
	}
	
	function del(aid){
		if(confirm("确定要删除？")){
			window.location.href = "${pageContext.request.contextPath }/address_deleteAddr.action?aid="+aid;
		}
	}
</script>
</head>
<body>

<%@ include file="header.jsp" %>	

<div class="container cart">

		<div class="span24">
				<table>
					<tbody>
					<tr>
						<td colspan="4" align="left" style="font-size:16px;">我的收货地址</td>
					</tr>
					<tr>
						<th>收货人</th>
						<th>收货地址</th>
						<th>联系电话</th>
						<th>操作</th>
					</tr>
					<s:iterator var="adr" value="addrList">
						<tr>
							<td width="100">
								<s:property value="#adr.name"/>
							</td>
							<td>
								<s:property value="#adr.region"/>-<s:property value="#adr.addr"/>
							</td>
							<td>
								<s:property value="#adr.phone"/>
							</td>
							<td width="115" >
                            	<a href="javascript:JqueryDialog.Open('修改页面', 'address_editAddr.action?aid=<s:property value="#adr.aid"/>', 482, 354);" class="delete">修改</a> |
								<a href="javascript:del(<s:property value="#adr.aid"/>)" class="delete" >删除</a>
							</td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
			<br /><br />
			<form name="addrForm" action="${pageContext.request.contextPath }/address_insertAddrSubmit.action" method="post" onsubmit="return checkForm()">
				<div class="span24" style="width:60%">
				<p id="p1" style="display:none;color:red;"></p>
				<table>
					<tbody >
						<tr>
							<td colspan="4" align="left" style="font-size:16px;">新增收货地址</td>
						</tr>
						<tr>
							<th width="30%">收货人:</th>
							<td>
								<input id="name" name="name" type="text" value="" style="width:150px" />
							</td>
						</tr>
						<tr>
							<th width="30%">所在小区:</th>
							<td>
								<select id="area" name="area">
		                        	<option >----网店服务区----</option>
		                        	<option value="东方名城">东方名城</option>
		                        </select>
		                        <select class="region">
		                        	<option value="0" selected="selected">----请选择小区----</option>
		                        </select>
		                        <select id="region" name="region" class="region">
		                        	<s:iterator var="r" value="regions">
		                        		<option value="<s:property value="#r.rname"/>"><s:property value="#r.rname"/></option>
		                        	</s:iterator>
		                        </select>
							</td>
						</tr>
						<tr>
							<th width="30%">详细地址:</th>
							<td>
								<input id="addr" name="addr" type="text" value="" style="width:150px" />
							</td>
						</tr>
						<tr>
							<th width="30%">手机号码:</th>
							<td>
								<input id="phone" name="phone" type="text"value="" style="width:150px" />
							</td>
						</tr>
						<tr>
							<th width="30%">&nbsp;</th>
							<td>
								<input type="submit" value="保存" />
							</td>
						</tr>
					</tbody>
				</table>
				</div>
			</form>
		</div>
	</div>
<%@ include file="footer.jsp" %>	
</body>
</html>
